/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.hitechbangla.fctu.base.radar;

import com.hitechbangla.fctu.base.Location;
import com.hitechbangla.fctu.base.aircraft.Aircraft;
import java.awt.Color;
import java.awt.Graphics;
import java.io.Serializable;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Irteza
 */
public class Detected implements Serializable
{

    /**
     * @return the aircraft
     */
    public Aircraft getAircraft() {
	return aircraft;
    }

    /**
     * @return the listLocation
     */
    public List<Location> getListLocation() {
	return listLocation;
    }

    /**
     * @param listLocation the listLocation to set
     */
    public void setListLocation(List<Location> listLocation) {
	this.listLocation = listLocation;
    }
    private enum assignableColor{
	hostile,
	x_raid,
	target,
	intercptor,
	allied,
	bomber
    }
    private String trackNumber;
    private String idNumber;
    private assignableColor assignedColor;
    private Aircraft aircraft;
    private int aircraftPositionX;
    private int aircraftPositionY;
    private float heading;
    private double height;
    private float speed;

    // added by deb kanti
    private List<Location> listLocation;
    
    //
    public float getHeading() {
       DecimalFormat oneDForm = new DecimalFormat("###.#");
       return Float.valueOf(oneDForm.format(heading));
    }
   

    public float getHeight() {
        
        DecimalFormat oneDForm = new DecimalFormat("####.#");
        return Float.valueOf(oneDForm.format(height));
    }

    public float getSpeed() {
        DecimalFormat oneDForm = new DecimalFormat("####.#");
        return Float.valueOf(oneDForm.format(speed));
        //return speed;
    }       
    
    public Detected(Aircraft a)
    {
	this.aircraft = a;
	
	aircraftPositionX = (int)a.getAircraftState().getLocation().getX();
	aircraftPositionY = (int)a.getAircraftState().getLocation().getY();	
        
        this.height =  a.getAircraftState().getLocation().getZ();
        this.heading = a.getAircraftState().getHeading();
        this.speed = a.getAircraftState().getSpeed();
        
	listLocation = new ArrayList<>();
	listLocation.add(new Location(aircraftPositionX, aircraftPositionY, 0));
	
	////System.out.println("from detected: detected object created, size " + listLocation.size());
    }

    public void drawLocation(Graphics g)
    {
	g.setColor(Color.BLUE);
	
	int index = listLocation.size()-2;
	
	if(index>=0)
	{
	    g.drawRect((int)listLocation.get(index).getX(), (int)listLocation.get(index).getY(), 3, 3);
	}    
	
	index--;
	if(index>=0)
	{
	    g.drawRect((int)listLocation.get(index).getX(), (int)listLocation.get(index).getY(), 3, 3);
	}
	
	index--;
	if(index>=0)
	{
	    g.drawRect((int)listLocation.get(index).getX(), (int)listLocation.get(index).getY(), 3, 3);
	}
    }
    
    public int getAcPosX(){
	return aircraftPositionX;
    }
    
    
    public int getAcPosY(){
	return aircraftPositionY;
    }
}